package JavaShengSai2;

import java.util.Scanner;

/**
 * 1. 作物杂交
 * https://www.lanqiao.cn/problems/506/learning/?page=2&first_category_id=1&tags=2020,%E7%9C%81%E8%B5%9B&tag_relation=intersection&sort=pass_rate&asc=0
 */
public class Main1 {
    static int n,m,k,t;
    // 种植时间、初始作物种类、杂交所需的时间、植物是否已经合成、记录各类物种合成所需的最短时间
    // visited 中1代表已经合成，0代表没有合成
    static int[] time, staSeed, maxTime, visited, res;
    // 杂交类型
    static int[][] h;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        n = scan.nextInt();
        m = scan.nextInt();
        k = scan.nextInt();
        t = scan.nextInt();
        res = new int[n + 1];
        time = new int[n + 1];
        for(int i = 1;i <= n;i++) {
            time[i] = scan.nextInt();
        }

        staSeed = new int[m];
        visited = new int[n + 1];
        for(int i = 0;i < m;i++) {
            staSeed[i] = scan.nextInt();
            visited[staSeed[i]] = 1;
        }

        h = new int[k][3];
        maxTime = new int[k];
        for(int i = 0;i < k;i++) {
            h[i][0] = scan.nextInt();
            h[i][1] = scan.nextInt();
            h[i][2] = scan.nextInt();
            maxTime[i] = Math.max(time[h[i][0]],time[h[i][1]]);
        }

        // 进行杂交
        int ret = dfs(t);
        System.out.println(ret);
        scan.close();
    }

    public static int dfs(int t) {
        if(visited[t] == 0) {
            // 没有合成目标，进行dfs操作
            int min = Integer.MAX_VALUE;
            // 遍历杂交的过程，也就是h
            for(int i = 0;i < k;i++) {
                if(h[i][2] == t) {
                    // 找到合成目标，进行操作
                    min = Math.min(min, (maxTime[i] + Math.max(dfs(h[i][0]),dfs(h[i][1]))));
                }
            }
            res[t] = min;
            visited[t] = 1;
            return min;
        }else{
            // 合成的话，将其对应的最小值返回
            return res[t];
        }
    }
}
